﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Products.ascx.cs" Inherits="MLM.Home.Controls.Products" %>
<%@ Import Namespace="MLM.Home" %>
<h3 class="main_title">
    Our products
</h3>
<div class="main_content">
    <div id="product_wrapper">
        <div id="product_filter">
            Country:
            <asp:DropDownList runat="server" ID="RabCountry" DataTextField="Name" DataValueField="CountryID"
                Width="150px" DataSourceID="CountriesEds" AutoPostBack="true" CssClass="HfCountryID" />
            Depo:
            <asp:DropDownList runat="server" ID="RadUser" DataSourceID="DepoEds" DataTextField="FullName"
                Width="150px" AutoPostBack="true" DataValueField="UserId" CssClass="HfUserID" />
        </div>
        <br />
        <asp:ListView runat="server" DataSourceID="ProductEds" ID="ProductLv">
            <ItemTemplate>
                <div class="product_item">
                    <div class="product_image">
                        <a href='<%#Eval("ProductBas.ProductCategoryID").LinkItemDetail(Eval("ProductBas.ProductBaseID"),Eval("ProductBas.Name"),Eval("ProductBas.Name"),"Product") %>'>
                            <asp:Image ID="ProductImage" runat="server" ImageUrl='<%# Eval("ProductBas.ThumbImage") %>' /></a>
                    </div>
                    <div class="product_title">
                        <b>
                            <%#Eval("ProductBas.ProductCategory.Name")%>
                            <%# Eval("ProductBas.Name")%></b>
                    </div>
                    <div class="product_price">
                        <%# Eval("ProductBas.Price")%>
                        &euro;</b>
                    </div>
                    <div>
                        <asp:TextBox runat="server" Class="CountProduct" ID="CountProduct" Width="148px"
                            Text="1"></asp:TextBox>
                        <a href="#" id="btnBuy" text="Buy" runat="server" class="CartOut" productid='<%#Eval("ProductBas.ProductBaseID") %>'>
                            Buy</a>
                    </div>
                </div>
            </ItemTemplate>
        </asp:ListView>
        <asp:Label runat="server" CssClass="" ID="HfCountryID" Visible="true"></asp:Label>
        <asp:Label runat="server" CssClass="" ID="HfUserID" Visible="true"></asp:Label>
        <asp:EntityDataSource ID="ProductEds" runat="server" ConnectionString="name=MLMDataContext"
             DefaultContainerName="MLMDataContext" EnableDelete="True"
            EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="UserStocks"
            Include="ProductBas" EntityTypeFilter="UserStock" Where="it.UserID=@userID and (it.ProductBas.ProductCategoryID=@catid || @catid=0)">
            <WhereParameters>
                <asp:ControlParameter PropertyName="SelectedValue" Type="Int64" Name="userID" ControlID="RadUser"
                    DefaultValue="0" />
                <asp:RouteParameter RouteKey="catid" Name="catid" ConvertEmptyStringToNull="True" DefaultValue="0" Type="Int64"/>
            </WhereParameters>
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="CountriesEds" runat="server" ConnectionString="name=MLMDataContext"
            DefaultContainerName="MLMDataContext" EnableDelete="True" EnableFlattening="False"
            EnableInsert="True" EnableUpdate="True" EntitySetName="Countries">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="DepoEds" runat="server" ConnectionString="name=MLMDataContext"
            AutoGenerateWhereClause="true" DefaultContainerName="MLMDataContext" EntitySetName="Users"
            Select="it.UserId,(it.FirstName +' '+ it.LastName) as FullName">
            <WhereParameters>
                <asp:ControlParameter ControlID="RabCountry" Name="CountryID" Type="Int64" PropertyName="SelectedValue" />
            </WhereParameters>
        </asp:EntityDataSource>
    </div>
    <div class="Pager">
        Page:
        <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ProductLv" PageSize="9"
            QueryStringField="p">
            <Fields>
                <asp:NumericPagerField runat="server" ButtonCount="10" />
            </Fields>
        </asp:DataPager>
    </div>
</div>
